package Controller.Member;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

import Bean.MemberBean;
import Dao.MemberDao;

public class MemberInsert extends AbstractCommandController{
	private MemberDao member;

	public void setMember(MemberDao member) {
		this.member = member;
	}

	@Override
	protected ModelAndView handle(HttpServletRequest req,
			HttpServletResponse res, Object obj, BindException arg3)
			throws Exception {
		req.setCharacterEncoding("UTF-8");
		MemberBean bean = (MemberBean)obj;
		
		System.out.println(" Request 로 뽑은결과 ");
		System.out.println(req.getParameter("m_id"));
		System.out.println(req.getParameter("m_pw"));
		System.out.println(req.getParameter("m_nickname"));
		System.out.println(req.getParameter("m_email"));
		System.out.println(req.getParameter("m_ssn1"));
		System.out.println(req.getParameter("m_ssn2"));
		System.out.println(req.getParameter("m_addres"));
		
/*		String m_id = req.getParameter("m_id");
		String m_pw = req.getParameter("m_pw");
		String m_nickname = req.getParameter("m_nickname");
		String m_email = req.getParameter("m_email");
		int m_ssn1 = Integer.parseInt(req.getParameter("m_ssn1"));
		int m_ssn2 = Integer.parseInt(req.getParameter("m_ssn2"));
		String m_addres = req.getParameter("m_addres");
		
		bean.setM_id(m_id);
		bean.setM_pw(m_pw);
		bean.setM_nickname(m_nickname);
		bean.setM_email(m_email);
		bean.setM_ssn1(m_ssn1);
		bean.setM_ssn2(m_ssn2);
		bean.setM_addres(m_addres);*/
		
		
		System.out.println(" Object 로 뽑은결과");
		System.out.println(bean.getM_id());
		System.out.println(bean.getM_pw());
		System.out.println(bean.getM_nickname());
		System.out.println(bean.getM_email());
		System.out.println(bean.getM_ssn1());
		System.out.println(bean.getM_ssn2());
		System.out.println(bean.getM_addres());
		
		ModelAndView mav = new ModelAndView();
		
		member.mInsert(bean);// ȸ�� �Ѹ��� ���� �о����
		mav.setViewName("redirect:/home.main");
		return mav;
	}
}
